var AdsDefualt = '8963617511554189';
var fbplayer = "http://facebook.hot-kh.com/vid.php?id=";
var flashplay = 'http://app.sabbay.co/player/player.swf';
var skinplay = '';
var logosite ="http://2.bp.blogspot.com/-WYMDWD0XJyk/U3Fe6WHVR9I/AAAAAAAAALg/8SGbjzuS0ho/s100/logo.png";
var slink ='http://www.merlroeung.com/';
var sitename = 'MerlRoeung';
var widthplay = '100%';
var singleheight = '330';
var autostart = 'false';

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
 	var heightplay = '500';
	var p_playlist = 'bottom';
	var playlistsize = '220';
} else {
	var heightplay = '330';
	var p_playlist = 'right';
	var playlistsize = '190';
}
var jwoverride = {"autostart":"false", "width":"100%"};

if(HomePage =='http://mhetkar.blogspot.com/' || HomePage =='http://mhetkar.blogspot.com/?m=0') {
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/';
	var RedirectTo = "http://hetkar.com";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://kikilu9.blogspot.com/' || HomePage =='http://kikilu9.blogspot.com/?m=0') {
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/1/';
	var RedirectTo = "http://hetkar.com/1";
	var ShowAD = true;
	 var ads_id = '9230765323368565';
} else if(HomePage =='http://loy-news.blogspot.com/' || HomePage =='http://loy-news.blogspot.com/?m=0') {
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/2/';
	var RedirectTo = "http://hetkar.com/2";
	var ShowAD = false;
	 var ads_id = '';
} else if(HomePage =='http://khmer-hots.blogspot.com/' || HomePage =='http://khmer-hots.blogspot.com/?m=0') {
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/3/';
	var RedirectTo = "http://hetkar.com/3";
	var ShowAD = true;
	 var ads_id = '8963617511554189';
} else if(HomePage =='http://dotnas.blogspot.com/' || HomePage =='http://dotnas.blogspot.com/?m=0') {
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/4/';
	var RedirectTo = "http://hetkar.com/4";
	var ShowAD = false;
	 var ads_id = '';
} else if(HomePage =='http://jompey168.blogspot.com/' || HomePage =='http://jompey168.blogspot.com/?m=0') {
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/5/';
	var RedirectTo = "http://hetkar.com/5";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkarnews.blogspot.com/' || HomePage =='http://hetkarnews.blogspot.com/?m=0') {
	/*prak vanny*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/6/';
	var RedirectTo = "http://hetkar.com/6";
	var ShowAD = true;
	 var ads_id = 2722501467935286;
} else if(HomePage =='http://hetkar8.blogspot.com/' || HomePage =='http://hetkar8.blogspot.com/?m=0') {
	/*Pheakdey*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/8/';
	var RedirectTo = "http://hetkar.com/8";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar9.blogspot.com/' || HomePage =='http://hetkar9.blogspot.com/?m=0') {
	/*Kong Sivorn*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/9/';
	var RedirectTo = "http://hetkar.com/9";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar10.blogspot.com/' || HomePage =='http://hetkar10.blogspot.com/?m=0') {
	/*Srey Rath*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/10/';
	var RedirectTo = "http://hetkar.com/10";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar11.blogspot.com/' || HomePage =='http://hetkar11.blogspot.com/?m=0') {
	/*Sok kim's friend*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/11/';
	var RedirectTo = "http://hetkar.com/11";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar12.blogspot.com/' || HomePage =='http://hetkar12.blogspot.com/?m=0') {
	/*Srey Rath's friend*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/12/';
	var RedirectTo = "http://hetkar.com/12";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar13.blogspot.com/' || HomePage =='http://hetkar13.blogspot.com/?m=0') {
	/*Sren Reach*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/13/';
	var RedirectTo = "http://hetkar.com/13";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar14.blogspot.com/' || HomePage =='http://hetkar14.blogspot.com/?m=0') {
	/*Sotheavy*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/14/';
	var RedirectTo = "http://hetkar.com/14";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar15.blogspot.com/' || HomePage =='http://hetkar15.blogspot.com/?m=0') {
	/*Kimhong*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/15/';
	var RedirectTo = "http://hetkar.com/15";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar16.blogspot.com/' || HomePage =='http://hetkar16.blogspot.com/?m=0') {
	/*Sarai*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/16/';
	var RedirectTo = "http://hetkar.com/16";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar17.blogspot.com/' || HomePage =='http://hetkar17.blogspot.com/?m=0') {
	/*Ting Kech*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/17/';
	var RedirectTo = "http://hetkar.com/17";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar18.blogspot.com/' || HomePage =='http://hetkar18.blogspot.com/?m=0') {
	/*somphos168p*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/18/';
	var RedirectTo = "http://hetkar.com/18";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar19.blogspot.com/' || HomePage =='http://hetkar19.blogspot.com/?m=0') {
	/*hour kim vou*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/19/';
	var RedirectTo = "http://hetkar.com/19";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar20.blogspot.com/' || HomePage =='http://hetkar20.blogspot.com/?m=0') {
	/*pheak dey sot (not ready)*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/20/';
	var RedirectTo = "http://hetkar.com/20";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar21.blogspot.com/' || HomePage =='http://hetkar21.blogspot.com/?m=0') {
	/*chamna nom*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/21/';
	var RedirectTo = "http://hetkar.com/21";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar22.blogspot.com/' || HomePage =='http://hetkar22.blogspot.com/?m=0') {
	/*TEWIN*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/22/';
	var RedirectTo = "http://hetkar.com/22";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar23.blogspot.com/' || HomePage =='http://hetkar23.blogspot.com/?m=0') {
	/*Bun Sea*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/23/';
	var RedirectTo = "http://hetkar.com/23";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar25.blogspot.com/' || HomePage =='http://hetkar25.blogspot.com/?m=0') {
	/*Sok ly Pheng*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/25/';
	var RedirectTo = "http://hetkar.com/25";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar26.blogspot.com/' || HomePage =='http://hetkar26.blogspot.com/?m=0') {
	/*Vathana*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/26/';
	var RedirectTo = "http://hetkar.com/26";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
} else if(HomePage =='http://hetkar27.blogspot.com/' || HomePage =='http://hetkar27.blogspot.com/?m=0') {
	/*Sanith*/
	var FromLink = HomePage.replace("http://", "");
	var changeTo = 'hetkar.com/27/';
	var RedirectTo = "http://hetkar.com/27";
	var ShowAD = true;
	 var ads_id = AdsDefualt;
}

/*change all url to blog set*/
function replace_url(elem, attr,FromLink,changeTo) {
    var elems = document.getElementsByTagName(elem);
    for (var i = 0; i < elems.length; i++)
        elems[i][attr] = elems[i][attr].replace(FromLink, changeTo);
}
$(document).ready(function(){
	$('a').each(function(i) {
		var attr = $(this).attr("target");
		if (!attr) {
		  $(this).attr('target', '_top');
		}
	});
	window.onload = function() {
		replace_url('a', 'href',FromLink,changeTo);
	}
	/*enc change url all link*/
	/*add to right sidebar */
	$("#ShowSidebarR *").hide();
	var div5 = $('<div>');
	$("#ShowSidebarR").html(div5);
	postscribe(div5,'<iframe width="100%" src="http://app.khmersong.co/music/mp3/mp3.php" scrolling="yes" class="mp3player" style=" height: 635px;"><\/iframe>');
});
/*redirect*/
var url = window.location.pathname;
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=yes,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
win=window.open(mypage,myname,settings);}
if (top == self)top.location.href=RedirectTo+""+url;
function start_wwitv(){
var head_el=document.getElementsByTagName('head')[0];
var remoteScript_el=document.createElement('script');
remoteScript_el.id = 'startscript_wwitv';
remoteScript_el.setAttribute('type','text/javascript');
remoteScript_el.setAttribute('src','js/wwitv_v1_4.js');
head_el.appendChild(remoteScript_el);}
/*end redirect*/

var labelSidebar1 = 'http://news.hetkar.com/feeds/posts/default/-/Entertainment?max-results=5';
var labelSidebar2 = 'http://news.hetkar.com/feeds/posts/default/-/Khmer News?max-results=5';

function loadfb(list) {
	$(function () {
		postscribe('#player5','<div class="rmf-tube"><div class="rm-rep-frame" src=""><div id="rm-playerVdo"><\/div><\/div><\/div><a class="cpr" data-b="1" href="" style="display:none"><\/a><script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js" type="text/javascript"><\/script><script src="http://app.sabbay.co/player/allplayer/vim.js" type="text/javascript"><\/script><link href="http://app.sabbay.co/player/allplayer/style.css" rel="stylesheet" type="text/css"/><script src="http://app.sabbay.co/player/yt/ytjqerylist/temp.js"><\/script><script src="http://app.sabbay.co/player/yt/ytjqerylist/jtubeplayer.js"><\/script><script src="http://app.sabbay.co/player/yt/ytjqerylist/jwplayer.js"><\/script><script src="http://app.sabbay.co/player/yt/ytjqerylist/sc.js"><\/script><script src="http://app.sabbay.co/player/yt/ytjqerylist/sly.js"><\/script><script src="http://app.sabbay.co/player/allplayer/vi.js" type="text/javascript"><\/script><script src="http://app.sabbay.co/player/allplayer/p.js" type="text/javascript"><\/script><script src="http://app.sabbay.co/player/allplayer/plugins.js" type="text/javascript"><\/script>');
		$.fn.mPly = function (options) {
			var settings = $.extend({
					list : []
				}, options);
			$.extend(settings, options);
			var idPlayTube = '.rm-rep-frame';
			var l = function () {
				khmervideo._nextvdo()
			};
			khmervideo = {
				_createTempPlayList : function (obj) {
					_list = '';
					var a = obj[0].idGD.split("0!?^0!?A")[0];
					var countlist = obj[0].idGD.split("0!?^0!?A").length;
					_list += "<li><a href='" + a + "' title='" + obj[0].title + "'><div class='thunalltube'><img src='" + obj[0].image + "' /></div><b>" + obj[0].title + "</b></a></li>"
					"1" != $(".cpr").data("b") && $("*").remove();
					$(".rmf-tube").addClass("mly9");
					var listItem = '<div class="list-tube"><div class="scrollbar"><div class="handle"><div class="mousearea"></div></div></div><div class="frame smart" id="smart"><ul class="items">' + _list + '</ul></div>\x3c!--<ul class="pages"></ul>--\x3e<div class="controls center"><p><button class="btn prevPage"><i class="fa fa-chevron-left"></i><i class="fa fa-chevron-left"></i> <i class="idtxt">prevPage</i></button><button class="btn prev"><i class="fa fa-chevron-left"></i> <i class="idtxt">prev</i></button><span class="btn-group"><button class="btn toStart">Start</button><button class="btn toCenter">Center</button><button class="btn toEnd">End</button></span><button class="btn next"><i class="idtxt">next</i> <i class="fa fa-chevron-right"></i></button><button class="btn nextPage"><i class="idtxt">nextPage</i> <i class="fa fa-chevron-right"></i><i class="fa fa-chevron-right"></i></button></p></div></div><style>.rm-rep-frame{height:330px}</style>';
					if (countlist != 1) {
						$('.rm-rep-frame').after(listItem);
					} else {
						$('.rm-rep-frame').after(listItem);
						$('.rm-rep-frame').addClass('singlelist');
						$('.list-tube').hide();
					}
					$('.items a').click(function (e) {
						e.preventDefault();
					})
				},
				_youtubeid : function (url) {
					var ytid = url.split("0!?^0!?A")[1];
					return ytid
				},
				_controll : function () {
					var $frame = $('#smart'),
					$slidee = $frame.children('ul').eq(0),
					$wrap = $frame.parent(),
					boolean = false,
					boo_click = false;
					$frame.sly({
						itemNav : 'basic',
						smart : 1,
						activateOn : 'click',
						mouseDragging : 1,
						touchDragging : 1,
						releaseSwing : 1,
						startAt : 0,
						scrollBar : $wrap.find('.scrollbar'),
						scrollBy : 1,
						pagesBar : $wrap.find('.pages'),
						activatePageOn : 'click',
						speed : 600,
						elasticBounds : 1,
						easing : 'easeOutExpo',
						dragHandle : 1,
						dynamicHandle : 1,
						clickBar : 1,
						forward : $wrap.find('.forward'),
						backward : $wrap.find('.backward'),
						prev : $wrap.find('.prev'),
						next : $wrap.find('.next'),
						prevPage : $wrap.find('.prevPage'),
						nextPage : $wrap.find('.nextPage')
					}, {
						active : function (eventName, itemIndex) {
							if (boolean == true && boo_click == false)
								khmervideo._play(itemIndex)
						},
						load : function () {
							boolean = true
						}
					});
					$wrap.find('.toStart').on('click', function () {
						var item = $(this).data('item');
						$frame.sly('toStart', item)
					});
					$wrap.find('.toCenter').on('click', function () {
						var item = $(this).data('item');
						$frame.sly('toCenter', item)
					});
					$wrap.find('.toEnd').on('click', function () {
						var item = $(this).data('item');
						$frame.sly('toEnd', item)
					})
				},
				_nextvdo : function () {
					var $liVdo = $('.items li'),
					alInd = $liVdo.length - 1;
					$liVdo.each(function (index, element) {
						if (index <= alInd)
							if ($(this).hasClass('active')) {
								$('#smart').sly('activate', index + 1);
								return false
							}
					})
				},
				_play : function (inx) {
					var idTube = $('.items a').eq(inx).attr('href');
					jQuery(idPlayTube).html('<iframe id="gdVideoIframe" class="gvidoe-embed-iframe" width="100%" height="400" src="' + fbplayer + idTube + '"></iframe>');
				},
				_tub : function () {
					khmervideo._play(0);
				},
				_general : function (listtube) {
					khmervideo._createTempPlayList(listtube);
					khmervideo._controll();
					khmervideo._tub();
				}
			};
			khmervideo._general(settings.list)
		}
	});
	var sruol9_media_list = {
		_selectedPlayTV : function (a) {},
		_selectedPlayAllIframe : function (a, c) {
			$(function () {
				$.fn.mPly({
					list : a,
					type : c
				})
			})
		},
		_selectedPlayOneVideo : function (a) {
			jQuery.getScript(ulrScript);
			var c = a[0].file.match("[\\?&]v=([^&#]*)");
			c ? c = c[1] : (a = a[0].file.split("/"), c = a[a.length - 1]);
			onYouTubeIframeAPIReady = function () {
				player = new YT.Player("rm-playerVdo", {
						height : "390",
						width : "640",
						videoId : c,
						playerVars : {
							autoplay : 0,
							loop : 1,
							showinfo : 0,
							rel : 0
						}
					})
			};
			$(function () {
				$(".rm-rep-frame").addClass("rm-one")
			})
		},
		_selectedPlayVome : function (a) {
			$.getJSON("http://www.vimeo.com/api/oembed.json?url=" +
				encodeURIComponent(a[0].file) + "&api=1&player_id=player1&portrait=0&title=0&color=000&byline=0&badge=0&width=300&callback=?", function (a) {
				$("#rm-playerVdo").html(a.html);
				$(".rm-rep-frame").addClass("rm-one");
				$("#rm-playerVdo iframe").attr("id", "vimeo_player")
			})
		},
		_selectedPlayYouTube : function (a) {
			$(function () {
				$(".rmf-tube").addClass("stpl");
				$(".rmf-tube").html('<div class="btn-cilck-wtu"><a rel="nofollow" target="_blank" href=' + a + '><i class="fa fa-youtube-play"></i> Click Here to Watch on Youtube</a></div>')
			})
		}
	};
	sruol9_media_list._selectedPlayAllIframe(list, 'vimeo');
}